package com.olc.railing.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by DELL on 2017/9/7.
 */
public class SharedUtils {


  

    public static void setEntranceTime(Context context, String entranceTime) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("entranceTime", entranceTime);
        editor.commit();
    }

    public static String getEntranceTime(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("entranceTime", "");
    }



    public static void setCloseType(Context context, String closeType) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("closeType", closeType);
        editor.commit();
    }

    public static String getCloseType(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("closeType", "1");
    }




    public static String getSerialNo(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("serialNo", "");
    }

    public static void setSerialNo(Context context, String serialNo) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("serialNo", serialNo);
        editor.commit();
    }


    public static String getOilGunNo(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("oilGun", "");
    }

    public static void setOilGunNo(Context context, String oilGun) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("oilGun", oilGun);
        editor.commit();
    }

    public static String getIpAdress(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("ipAdress", "");
    }

    public static void setIpAdress(Context context, String ipAdress) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("ipAdress", ipAdress);
        editor.commit();
    }

    public static String getName(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("name", "");
    }

    public static void setName(Context context, String name) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("name", name);
        editor.commit();
    }


    public static String getId(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("id", "");
    }

    public static void setId(Context context, String id) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("id", id);
        editor.commit();
    }

    public static String getFlag(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("flag", "");
    }

    public static void setFlag(Context context, String id) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("flag", id);
        editor.commit();
    }

    public static void clear(Context context) {
        SharedPreferences preferences = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = preferences.edit();
        editor.clear();
        editor.commit();
    }


    public static String getAdPhotoUrl(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("adPhotoUrl", "");
    }

    public static void setAdPhotoUrl(Context context, String adPhotoUrl) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("adPhotoUrl", adPhotoUrl);
        editor.commit();
    }

    public static String getAdJumpLink(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("jumpLink", "");
    }

    public static void setAdJumpLink(Context context, String jumpLink) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("jumpLink", jumpLink);
        editor.commit();
    }

    public static String getAdId(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("id", "");
    }

    public static void setAdId(Context context, String adId) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("id", adId);
        editor.commit();
    }
    public static String getFileName(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("fileName", "");
    }

    public static void setFileName(Context context, String fileName) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("fileName", fileName);
        editor.commit();
    }

    public static String getCardNoStr(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("cardNoStr", "");
    }

    public static void setCardNoStr(Context context, String cardNo) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("cardNoStr", cardNo);
        editor.commit();
    }

    public static String getDeviceTokenStr(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("deviceToken", "");
    }

    public static void setDeviceTokenStr(Context context, String deviceToken) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("deviceToken", deviceToken);
        editor.commit();
    }
    public static String getRepairUserType(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("repairUserType", "");
    }

    public static void setRepairUserType(Context context, String userType) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("repairUserType", userType);
        editor.commit();
    }
    public static String getPollingType(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getString("pollingType", "");
    }

    public static void setPollingType(Context context, String pollingType) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putString("pollingType", pollingType);
        editor.commit();
    }

    public static boolean isShowDakaView(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getBoolean("isShow", true);
    }

    public static void setIsShowDakaView(Context context, boolean isOpen) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putBoolean("isShow", isOpen);
        editor.commit();
    }

    public static boolean isAgreementProtol(Context context) {
        SharedPreferences sp = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE);
        return sp.getBoolean("isAgree", false);
    }

    public static void setIsAgreementProtol(Context context, boolean isAgree) {
        SharedPreferences.Editor editor = context.getSharedPreferences("raling_config", Context.MODE_PRIVATE).edit();
        editor.putBoolean("isAgree", isAgree);
        editor.commit();
    }
}
